//
//  tryThrowCatch.cpp
//  learnC++
//
//  Created by liuzhibing on 2018/6/24.
//  Copyright © 2018年 yunfan.com. All rights reserved.
//

#include "tryThrowCatch.hpp"

CatchError::CatchError(){
    
}

void CatchError::base(){
    
    
    
    try {
        
        //statement
        outOfThrow(-1);
//        std::string name = "alex";
//        throw name;
//        throw -1;
//        throw 3.2;
//        编译器在将异常与catch块匹配时不会执行隐式转换
    } catch (int x) {
        
        std::cerr << "caught an int exception" << x << "\n";
        
    } catch (double) {
        std::cerr << "caught an double exception\n";
    } catch (const std::string &str) {
        std::cerr << "caught an string exception\n";
    } catch (const char * str) {
        std::cerr << "caught an char * exception\n";
    }
}

void CatchError::outOfThrow(int x){
    
    if (x < 0) {
        throw "THIS IS VALUE IS FALSE";
    }
    
}
